<?php

/* 
 * Copyright (c) 2009 Nguyen Duc Thuan <me@ndthuan.com>
 * All rights reserved.
 */

class Fete_View_Helper_Holder extends Fete_View_Helper
{
    protected $_holders = array();
    protected $_currentHolder = null;

    public function &holder($holder, $content = null)
    {
        $this->_currentHolder = $holder;
        if (null !== $content) {
            $this->_holders[$holder] = $content;
        }
        return $this;
    }

    public function &set($content)
    {
        $this->_holders[$this->_currentHolder] = $content;
        return $this;
    }

    public function &prepend($content)
    {
        $this->_holders[$this->_currentHolder] = $content
        . $this->_holders[$this->_currentHolder];
        return $this;
    }

    public function &append($content)
    {
        $this->_holders[$this->_currentHolder] .= $content;
        return $this;
    }

    public function __toString()
    {
        return $this->_holders[$this->_currentHolder];
    }
}